package com.pktechan.api.utils;

import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;


/**
 * 返回给服务器端的消息封装，包含了
 * <p/>
 * success：是否调用是否成功
 * <p/>
 * errorCode
 * <p/>
 * 错误代码
 * <p/>
 * errorMessage
 * <p/>
 * 错误消息
 * <p/>
 * data：返回的参数
 * <p/>
 * {
 * <p/>
 * "success": true,
 * <p/>
 * "errorCode":"",
 * <p/>
 * "errorMessage":"",
 * <p/>
 * "data":
 * "{\"id\":\"Id\",\"name\":\"Name\",\"email\":\"email@test.com\",\"address\":\"beijing\"}"
 * ,
 * <p/>
 *
 * @author WangJiahao
 * @version 1.0
 */
@XmlRootElement(name = "ResponseMessage")
public class ResponseMessage<T> implements Serializable {

    private static final long serialVersionUID = 677484458789332877L;
    //
    private boolean success = false;
    private String errorCode = "";
    private String errorMessage = "";
    private T data;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }


    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public void setData(T data) {
        if (data != null) {
            this.data = data;
        }
    }

    public T getData() {
        return data;
    }
}